﻿/// <reference path="../libraries/class.js" />

var Encryptor = Class.create({
	init: function () {
		this.salt = "929205012131";
	},
	encrypt: function (text) {
		//encode the string here
		var encryption = "";
		for (var i = 0; i < text.length; i++) {
			var encryptedCode = this.salt.charCodeAt(i % this.salt.length) ^ text.charCodeAt(i);
			encryption = encryption + String.fromCharCode(encryptedCode);
		}

		return encryption;
	},
	decrypt: function (codeString) {
		//decode the string here
		var decrypted = "";
		var encryptedCode;
		for (var i = 0; i < codeString.length; i++) {
			encryptedCode = this.salt.charCodeAt(i % this.salt.length) ^ codeString.charCodeAt(i);
			decrypted += String.fromCharCode(encryptedCode);
		}

		return decrypted;
	}
})